package com.shop.front.dao.store;


import com.shop.jpa.BaseSQLDao;
import com.shop.jpa.support.QuerySQL;
import com.shop.front.vo.store.StoreCartVo;
import com.shop.web.context.WebContext;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Repository;

@Repository
public class StoreCartSQLDao extends BaseSQLDao {


    public Page<StoreCartVo> page(Long userId) {
        String field = "sc.id, sc.product_id, sc.product_attr_value_id, sc.cart_num, sp.store_name, sp.store_info, sp.is_pink, spav.suk, spav.stock, spav.price, spav.pink_price, spav.origin_price, spav.image";
        String from = "t_store_cart sc left join t_store_product sp on sc.product_id = sp.id left join t_store_product_attr_value spav on sc.product_attr_value_id = spav.id";
        String order = "sc.id desc";

        QuerySQL qs = new QuerySQL(WebContext.getPageNo(), WebContext.getPageSize(), field, from, order);
        qs.addWhereWithoutParams("sc.is_deleted = 0 and sp.is_deleted = 0 and spav.is_deleted = 0 and sc.is_pay = 0 and sp.is_show = 1");
        qs.addWhereEq("sc.uid", userId);

        return this.page(qs, StoreCartVo.class);
    }



}
